package com.qf.annotation;

import org.springframework.context.annotation.Lazy;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author 10537
 * @version V1.0
 * @Date 2021/9/28 10:45
 */

@Component  //<bean id="people" class="com.qf.annotation">

//@Component(value="abc")       //<bean id="abc" class="com.qf.annotation">
//@Lazy
//@Scope(value = "singleton")   //默认单例
//@Scope(value = "prototype")     //多例

public class People {
    private String name="宁宁";
    private Integer age=24;

    public People() {
    }

    public People(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    @PostConstruct
    public void init(){
        System.out.println("创建完毕");
    }

    @PreDestroy
    public void destory(){
        System.out.println("销毁完毕");
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getAge() {
        return age;
    }

    public void setAge(Integer age) {
        this.age = age;
    }

    @Override
    public String toString() {
        return "People{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
